function process_quadcopter_data
close all
data = csvread('demo_flight_data.csv');
time = data(:,1); x = data(:,2); y = data(:,3);z = data(:,4);
ax = data(:,8); vx = data(:,5);
plot3(x,y,z);
grid on;
title('Trajectory'); xlabel('x (m)'); ylabel('y (m)'); zlabel('z (m)');
figure
plot(time,ax);
grid on;
title('Acceleration'); xlabel('time (s)'); ylabel('a_x (m/s^2)'); 
v_integrated = cumtrapz(time,ax);
figure
plot(time,v_integrated,'Displayname','Integrated a_x')
hold on
plot(time,vx,'Displayname','v_x from quadcopter')
for i = 1:length(time) - 1
    T(i) = (time(i+1) + time(i))/2;
    v_differentiated(i) = (x(i+1)-x(i))/(time(i+1)-time(i));
end
%plot(T,v_differentiated);
v_smoothed = smooth(v_differentiated);
plot(T,v_smoothed,'Displayname','Differentiated x');
grid on; 
title('Velocity Calculations'); xlabel('time (s)'); ylabel('v_x (m/s)');
legend(gca,'show');

end